﻿@model IEnumerable<EquipManagement.Models.ApplicationRecord>

@{
    ViewBag.Title = "使用记录";
}

<h2>使用记录</h2>


<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Equipment.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Applicant)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Contact)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StudentInfo)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ApplicationDate)
        </th>
        <th>

            @Html.DisplayNameFor(model => model.ReturnDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.IsApprove)
        </th>

        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Equipment.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Applicant)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.StudentInfo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ApplicationDate)
            </td>
            <td>
                @if (item.ReturnDate != item.ApplicationDate)
                {
                    @Html.DisplayFor(modelItem => item.ReturnDate)
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsApprove)
            </td>

            <td>
                @if (!item.IsApprove && !item.Equipment.Status)
                {
                    <text>
                        @using (Html.BeginForm("Approve", "ApplicationRecords"))
                        {
                            <input type="hidden" name="Id" value="@item.Id" />
                            <button type="submit" onclick="return confirm('确认审批？');">审批</button>
                        }
                    </text>
                }
                else if (item.IsApprove && item.Equipment.Status)
                {
                    <text>
                        @using (Html.BeginForm("Return", "ApplicationRecords"))
                        {
                            <input type="hidden" name="Id" value="@item.Id" />
                            <button type="submit" onclick="return confirm('确认操作？');">归还</button>
                        }
                    </text>
                }
                
            </td>
        </tr>
    }

</table>
